using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;

namespace OhioState.Controls
{
    public partial class AlphaPicker : UserControl
    {
        public AlphaPicker()
        {
            InitializeComponent();
        }

        private void trackBar_Scroll(object sender, EventArgs e)
        {
            Value = trackBar.Value;
        }

        private void numericUpDown_ValueChanged(object sender, EventArgs e)
        {
            Value = (int)numericUpDown.Value;
        }

        private void colorPanel_Paint(object sender, PaintEventArgs e)
        {
            Color c = Color.FromArgb((Value * 255) / 100, 0, 0, 0);
            HatchBrush checker = new HatchBrush(HatchStyle.LargeCheckerBoard, Color.Gray, Color.White);

            e.Graphics.FillRectangle(checker, 0, 0, colorPanel.Width, colorPanel.Height);
            e.Graphics.FillRectangle(new SolidBrush(c), 0, 0, colorPanel.Width, colorPanel.Height);
        }

        public int Value
        {
            get
            {
                return (int)numericUpDown.Value;
            }
            set
            {
                numericUpDown.Value = value;
                trackBar.Value = value;
                colorPanel.Invalidate();
            }
        }
    }
}